package net.qiqbframework.eventhandling;

import javax.annotation.Nonnull;
import java.util.List;

public class ErrorContext {

    private final String eventProcessor;
    private final Throwable error;
    private final EventMessage<?> failedEvents;

    /**
     * Instantiate an ErrorContext for the given {@code eventProcessor}, due to the given {@code error}, with the given
     * {@code failedEvents}.
     *
     * @param eventProcessor the name of the event processor that failed to process the given events
     * @param error          the error that was raised during processing
     * @param failedEvents   the list of events that triggered the error
     */
    public ErrorContext(@Nonnull String eventProcessor, @Nonnull Throwable error,
                        @Nonnull EventMessage<?> failedEvents) {
        this.eventProcessor = eventProcessor;
        this.error = error;
        this.failedEvents = failedEvents;
    }

    public String eventProcessor() {
        return eventProcessor;
    }


    public Throwable error() {
        return error;
    }


    public EventMessage<?> failedEvent() {
        return failedEvents;
    }
}
